/*  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
#ifndef luge_color_hh
#define luge_color_hh

#include <lua.h>
#include <gegl.h>
#include <string>

namespace luge {

/**
 * convert a gegl-color to a string for printing.
 */
std::string color_to_string (GeglColor *color);

/**
 * constructor function for colors. This is a lua-function.
 */
int color_construct (lua_State *ls);

/**
 * return true, iff the object at idx is a color.
 * It does not check if the object could be converted to a color.
 */
bool is_color (lua_State *ls, int idx);

/**
 * convert the object at the given index to a color.
 * A string will be converted to color using gegl_color_new.
 * A number will be converted by making r,g,b the value with alpha = 1.
 * Returns 0 if the object could not be converted to a color.
 */
GeglColor *to_color (lua_State *ls, int idx);

/**
 * create a color based on rgba.
 */
GeglColor *rgba_color (float r, float g, float b, float a);

/**
 * push a color onto the stack. This increases the reference
 * count of the color.
 */
void push_color (lua_State *ls, GeglColor *color);

} /* namespace luge */

#endif
